package com.baogang.controller;


import com.baogang.entity.SwingCardRecord;
import com.baogang.service.SwingCardRecordService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 赵自强
 * @since 2020-11-20
 */
@RestController
@RequestMapping("/api/syn_ai")
@Slf4j
public class SwingCardRecordController {
    @Resource
    private SwingCardRecordService swingCardRecordService;

    @GetMapping("/swr")
    public List<SwingCardRecord> lastDay() {
        List<SwingCardRecord> lastDaysData = swingCardRecordService.getLastDaysData();
        log.info("data count of last day: {}", lastDaysData.size());
        if (lastDaysData.size() != 0) {
            log.info("first data info:{}", lastDaysData.get(0).toString());
            log.info("last data info:{}", lastDaysData.get(lastDaysData.size() - 1).toString());
        }else {
            log.error("last day no data.");
        }
        return lastDaysData;
    }

    @GetMapping("/dop")
    public String post() {
        return swingCardRecordService.doPost();
    }
}
